package com.ruoyi.project.charge.pcharge.service.impl;

import com.ruoyi.project.charge.pcharge.domain.*;
import com.ruoyi.project.charge.pcharge.mapper.PChargeMapper;
import com.ruoyi.project.charge.pcharge.service.IPChargeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author : HUA°
 * @date : 17:12 2021/7/14
 */
@Service
public class PChargeServiceImpl implements IPChargeService {

    @Autowired
    private PChargeMapper pChargeMapper;


    /**
     * 根据挂号id查询
     * @param roId
     * @return
     */
    @Override
    public Map<String,Object> selectById(String roId) {
        Map<String,Object> map = new HashMap<>();

         RegOrder regOrder=pChargeMapper.findById(roId);
         System.out.println(regOrder);
        map.put("regOrder", regOrder);
         if(regOrder!=null){
             List<RegDrug> drug = pChargeMapper.findByRoID(roId);
             System.out.println(drug);
             map.put("drug", drug);
             List<RegCheck> checks = pChargeMapper.findCheckByRoId(roId);
             System.out.println(checks);
             map.put("checks",checks);
         }


        return map;
    }

    @Override
    public Map<String, Object> selectByRrId(String reRrId) {
        Map<String,Object> map = new HashMap<>();
        RegDisease regDisease = pChargeMapper.findByRrId(reRrId);
        System.out.println(regDisease);
        map.put("regDisease", regDisease);
        if(regDisease != null){
            List<RegDrug> drug = pChargeMapper.findByRoID(reRrId);
            System.out.println(drug);
            map.put("drug", drug);
            List<RegCheck> checks = pChargeMapper.findCheckByRoId(reRrId);
            System.out.println(checks);
            map.put("checks",checks);
        }
        return map;
    }

    /**
     * 根据挂号id和患者姓名进行查询
     * @param charge
     * @return
     */
    @Override
    public List<Charge> selectCharge(Charge charge) {
        List<Charge> list = pChargeMapper.findCharge(charge);
        System.out.println(list);
        return list;
    }
}
